package com.funcpro.server.controller;

import com.funcpro.common.Response.BaseResponse;
import com.funcpro.common.utils.PageUtils;
import com.funcpro.model.vo.LoginUser;
import com.funcpro.service.UserService;
import com.github.pagehelper.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author ZYT
 * @desc
 * @time 2023-11-08 13:22
 */

@RestController
@RequestMapping("uc")
public class UserController {

    @Resource
    private UserService userService;

    @PostMapping("/login")
    public BaseResponse login(@RequestBody LoginUser loginUser){
        return BaseResponse.ok(userService.login(loginUser));
    }

    @GetMapping("/query")
    public BaseResponse query(@RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,
                              @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize ){
        Page<LoginUser> list=userService.query(pageNo,pageSize);
        return BaseResponse.ok(PageUtils.listToJsonObject(list));
    }


}
